<template>
  <AmisFormComponent v-if="isShow" :formContext="amisFormContextObj" />
</template>

<script lang="ts" setup>
import {AmisFormContext} from "@/components/AmisFormComponent/amisFormContext";
import AmisFormComponent from "@/components/AmisFormComponent/AmisFormComponent.vue";
import { PropType } from 'vue'


defineOptions({name: 'AmisFormDetail'})

const {query} = useRoute() // 路由信息
const schema = ref()
const isShow = ref(false)

const amisFormContextObj = ref<AmisFormContext>({}) // amisForm 的 上下文数据

console.log("query",query)


const props = defineProps({
  amisFormId: {
    type: String ,
    required: false,
    default: null
  },
  formReadOnly: {
    type: Boolean,
    required:false,
    default: () => {
      return false
    }
  },
  hideButtons: {
    type: Boolean,
    required:false,
    default: () => {
      return false
    }
  },
})

/** 初始化 **/
onBeforeMount(async () => {
  console.log("onMounted...")
  if(props.amisFormId != null){
    amisFormContextObj.value.amisFormId = props.amisFormId;
    amisFormContextObj.value.readOnlyAmis = props.readOnlyAmis
    amisFormContextObj.value.hideAmisButton = props.hideAmisButton
  }else {
    amisFormContextObj.value.amisFormId = query.amisFormId;
    amisFormContextObj.value.readOnlyAmis = query.readOnlyAmis
    amisFormContextObj.value.hideAmisButton = query.hideAmisButton
  }


  isShow.value=true
})

</script>
